package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"willow/appendonly"
	"willow/cachestring"
	"willow/command"
	"willow/common/conf"
	_ "willow/common/conf/initialization" //提前加载配置读取文件
	_ "willow/common/logs"                //提前加载日志文件

)

func init() {
	cachestring.InitConst()
	if conf.WillowConf["appendonlyC"] == "aof" {
		appendonly.RestoreAof()
	} else {

	}
}

func main() {
	//strName := "willow"
	//strValue := "iyou"
	//strValue1 := "9090"
	//temp := &cachestring.WList{}
	//temp.LPush(strName,strValue)
	//temp.LPush(strName,strValue1)
	//fmt.Println(temp.BRPop(strName))
	//fmt.Println(temp.BRPop(strName))
	//fmt.Println(temp.BRPop(strName))
	//cachestring.G(strName)




	input := bufio.NewScanner(os.Stdin)		//初始化一个扫表对象
	fmt.Print("请输入命令：")
	for input.Scan() {						//扫描输入内容
		line := input.Text()				//把输入内容转换为字符串
		if strings.ToLower(line) == "exit" {
			break
		}
		temp := command.Parameter(line,true)
		if temp == 1 && line != ""{
			appendonly.SaveCommand(line)
		} else if temp == -1 {
			fmt.Println("The command entered does not exist")
		}
		fmt.Print("请输入命令：")
	}
}
